class CreateBlogs < ActiveRecord::Migration[5.1]
  def up
    create_table :blogs do |t|
      t.text :title
      t.text :content
      t.references :user, foreign_key: true
      t.integer :like_count, default: 0
      t.integer :dislike_count, default: 0
      t.integer :comments_count, default: 0
      t.integer :follower_count, default: 0

      t.timestamps
    end

    add_index :blogs, [:user_id, :created_at]

  end

  def down
    drop_table :blogs
  end

end
